package opdb

const (
	AX   = 0
	DX   = 1
	I2   = 2
	I4   = 3
	R8   = 4
	I8   = 5
	TEXT = 6
	BLOB = 7

	//QBad 质量
	QBad = 0x200
	//QTimeout 超时
	QTimeout = 0x8000
)

type Type byte

func (t Type) String() string {
	return TypeString(byte(t))
}

func ParseType(text string) Type {
	return Type(PointType(text))
}

func PointType(typ string) byte {
	switch typ {
	case "AX", "0":
		return 0
	case "DX", "1":
		return 1
	case "I2", "2":
		return 2
	case "I4", "3":
		return 3
	case "R8", "4":
		return 4
	case "I8", "5":
		return 5
	case "TEXT", "6":
		return 6
	case "BLOB", "7":
		return 7
	}
	return 0
}

func TypeString(typ byte) string {
	switch typ {
	case AX:
		return "AX"
	case DX:
		return "DX"
	case I2:
		return "I2"
	case I4:
		return "I4"
	case R8:
		return "R8"
	case I8:
		return "I8"
	case TEXT:
		return "TEXT"
	case BLOB:
		return "BLOB"
	}
	return "AX"
}
